<?

abstract class JCAT_HTMLResourceBase
	implements JCAT_IHTMLResource
{
	/**
	 * 编译 HTML 节点属性字串
	 *
	 * @access	protected
	 * @return	string
	 */
	protected function MakeHTMLNodeAttributeStream()
	{
		$arrAttributes = array() ;
		foreach($this->arrHTMLNodeAttributes as $sAttrName=>$sAttrValue)
		{
			$arrAttributes[] = "{$sAttrName}=\"{$sAttrValue}\"" ;
		}
		
		return implode(' ',$arrAttributes) ;
	}
	
	/**
	 *
	 * @access	public
	 * @param	$sUrl	string
	 * @return	void
	 */
	public function JCAT_HTMLResourceBase($sUrl)
	{
		JCAT_ASSERT::ASSERT_STRING($sUrl)  ;
		$this->sUrl = $sUrl ;
	}
	
	/**
	 * 取得对象的URL
	 *
	 * @access	public
	 * @return	string
	 */
	public function GetUrl()
	{
		return $this->sUrl ;
	}
	
	/**
	 * 取得访问对象的URL
	 *
	 * @access	public
	 * @return	string
	 */
	public function GetAccessUrl()
	{
		if( $this->IsLocal() )
		{
			return JCAT_DownloadFile::GetHTTPAccessPath($this->GetUrl()) ;
		}
		
		else 
		{
			return $this->GetUrl() ;
		}
	}
	
	/**
	 * 是否为本地资源
	 *
	 * @access	public
	 * @return	bool
	 */
	public function IsLocal()
	{
		return !strstr($this->GetUrl(),':') ;
	}
	
	
	
	/**
	 * 资源的 Url
	 * 
	 * @access	private
	 * @var		string
	 */
	private $sUrl = '' ;
	
	/**
	 * HTML 节点属性值
	 * 
	 * @access	private
	 * @var		array
	 */
	private $arrHTMLNodeAttributes = array() ;
}

?>